﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Common
{
    /// <summary>
    /// HospitalCmbCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class HospitalCmbCtrl : UserControl
    {
        private List<HospitalEnum> _hospitals = new List<HospitalEnum>();
        

        public HospitalCmbCtrl()
        {
            InitializeComponent();
            foreach (HospitalEnum item in Enum.GetValues(typeof(HospitalEnum)))
            {
                Hospitals.Add(item);
            }
            this._cmb.ItemsSource = Hospitals;
        }

        public object SelectedHospital
        {
            get { return (object)GetValue(SelectedHospitalProperty); }
            set { SetValue(SelectedHospitalProperty, value); }
        }

        public List<HospitalEnum> Hospitals
        {
            get
            {
                return _hospitals;
            }

            set
            {
                _hospitals = value;
            }
        }

        // Using a DependencyProperty as the backing store for SelectedHospital.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SelectedHospitalProperty =
            DependencyProperty.Register("SelectedHospital", typeof(object), typeof(HospitalCmbCtrl), new PropertyMetadata());



        public event EventHandler<SelectionChangedEventArgs> SelectionChanged;

        private void _cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //SelectedHospital = _cmb.SelectedValue;
            SelectionChanged?.Invoke(sender, e);
        }
    }
}
